package spade;

public class MessageTemplate extends BehaviourTemplate
{
	ACLTemplate	template	= null;

	public MessageTemplate(ACLTemplate template)
	{
		this.template = template;
	}

	public boolean match(ACLTemplate message)
	{
		return acl_match(message);
	}
	public boolean acl_match(ACLTemplate message)
	{
		if (template.getPerformative() != null
		        && template.getPerformative().equals(message.getPerformative()) == false)
			return false;
		else if (template.getConversationId() != null
		        && template.getConversationId().equals(
		                message.getConversationId()) == false)
			return false;
		else if (template.getSender() != null
		        && template.getSender().equals(message.getSender()) == false)
			return false;
		else if (template.getReceivers() != null
		        & Util.equalsLists(template.getReceivers(), message
		                .getReceivers()) == false)
			return false;
		else if (template.getReplyTo() != null
		        && template.getReplyTo().equals(message.getReplyTo()) == false)
			return false;
		else if (template.getContent() != null
		        && template.getContent().equals(message.getContent()) == false)
			return false;
		else if (template.getReplyWith() != null
		        && template.getReplyWith().equals(message.getReplyWith()) == false)
			return false;
		else if (template.getReplyBy() != null
		        && template.getReplyBy().equals(message.getReplyBy()) == false)
			return false;
		else if (template.getInReplyTo() != null
		        && template.getInReplyTo().equals(message.getInReplyTo()) == false)
			return false;
		else if (template.getEncoding() != null
		        && template.getEncoding().equals(message.getEncoding()) == false)
			return false;
		else if (template.getLanguage() != null
		        && template.getLanguage().equals(message.getLanguage()) == false)
			return false;
		else if (template.getOntology() != null
		        && template.getOntology().equals(message.getOntology()) == false)
			return false;
		else if (template.getProtocol() != null
		        && template.getProtocol().equals(message.getProtocol()) == false)
			return false;
		else
			return true;
	}
}
